/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package we.dispatcher.reader.impl;

import we.dispatcher.CPacketReader;
import we.dispatcher.reader.IReadingProcessor;
import we.exception.UnsupportedTypeException;

/**
 *
 * @author trungdv2
 */
public class CTemplateProcessor implements IReadingProcessor {

    private Class _class;

    public CTemplateProcessor(Class _class) {
        this._class = _class;
    }

    @Override
    public Object read(CPacketReader reader) {
//        if (_class == String.class) {
//            return reader.readString();            
//        } else 
        if (_class == Byte.class) {
            return reader.buffer().get();
        } else if (_class == Integer.class) {
            return reader.buffer().getInt();
        } else if (_class == Long.class) {
            return reader.buffer().getLong();
        } else if (_class == Short.class) {
            return reader.buffer().getShort();
        }
        return null;
    }
}
